home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 3 / CU Amiga Magazine's Super CD-ROM 03 (1996)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1996-09].iso / misc / readers_utils / aslplaysound / aslplaysound.s < prev    next >
Text File  |  1992-09-02  |  5KB  |  443 lines

  1. ;ASlPlaySound
  2. ;By Mark Retallack
  3.  
  4.  
  5. ;includes
  6.  
  7.  
  8.     include    exec/exec.i
  9.     include    exec/exec_lib.i
  10.     include    libraries/asl.i
  11.     include    libraries/asl_lib.i
  12.     include dos/dos_lib.i            include dos commands
  13.     include dos/dos.i            include dos working    
  14.     
  15.  
  16. FSGetSize    EQU    -30
  17. FSLoadSound    EQU    -36
  18. FSPlaySound    EQU    -42
  19. FSStopSound    EQU    -48
  20.  
  21.  
  22. CALLFU    MACRO
  23.     move.l    _futurebase,a6
  24.     jsr    FS\1(a6)
  25.     ENDM
  26.  
  27.  
  28.     
  29.     
  30. ;start of program -- open asl lib
  31.  
  32.     lea    aslname(pc),a1
  33.     moveq    #0,d0                dont care which version
  34.     CALLEXEC OpenLibrary
  35.     tst.l    d0
  36.     beq    exitcloseall            if didnt open
  37.  
  38.     move.l    d0,_ASLBase            store lib pointer
  39.  
  40.  
  41. ; open dos lib
  42.  
  43.     lea    dosname(pc),a1            Find dos name
  44.     moveq    #0,d0                Store version into d0
  45.        CALLEXEC    OpenLibrary            Call open lib
  46.     tst.l    d0                Test do
  47.     beq    exitcloseasl            If false then goaway
  48.     
  49.     move.l    d0,_DOSBase            Put address into DOSBase
  50.  
  51.  
  52. ; open the Future library
  53.     lea    funame(pc),a1            store funame in a1
  54.     moveq    #0,d0                dont care which version
  55.     CALLEXEC OpenLibrary
  56.     tst.l    d0                test d0 and set flag z if lib was opened
  57.     beq    exitclosedos                if flag z is not set goto goawayfast
  58.     move.l    d0,_futurebase            
  59.  
  60.     
  61. ;find handle
  62.     
  63.     
  64.         CALLDOS    Output                Call output
  65.     move.l    d0,_stdout            Move address to stdout
  66.     
  67.  
  68.  
  69.  
  70.     
  71. ;alloc the requester
  72.  
  73.  
  74.     move.l    #0,d0
  75.     lea    tags(pc),a0
  76.     
  77.     CALLASL    AllocAslRequest
  78.  
  79.     move.l    d0,aslreq
  80.     
  81. ;run the requester
  82.  
  83. runreq
  84.     move.l    aslreq,a0    
  85.     lea    tags(pc),a1
  86.  
  87.     CALLASL    AslRequest     
  88.     
  89.     move.l    d0,aslres
  90.  
  91.     
  92. ;test output
  93.  
  94.     cmp    #0,d0
  95.     
  96.     beq    freereq    
  97.     
  98.     
  99. ;update the patten
  100.  
  101.     
  102.     move.l    aslreq,a0
  103.     move.l    52(a0),a0
  104.     
  105.     
  106.     lea    pattern,a1
  107.     
  108. loop:    MOVE.B    (A0)+,(A1)+
  109.     BNE.S    loop
  110.     
  111.  
  112.  
  113.     
  114.         
  115. ;set the addresses
  116. settheaddrs
  117.  
  118.  
  119.  
  120.  
  121.  
  122.     move.l    #0,lstore        
  123.  
  124. loopy2    add.l    #1,lstore
  125.  
  126.     move.l    aslreq,a0
  127.     move.l    36(a0),d0
  128.     
  129.     
  130.     move.l    lstore,d2
  131.     
  132.     sub.l    #1,d2
  133.     
  134.     mulu.l    #8,d2
  135.     
  136.     add.l    #4,d2
  137.             
  138.     add.l    d2,d0
  139.     
  140.     
  141.     move.l    d0,a0    
  142.     move.l    (a0),aslfile    
  143.  
  144.  
  145.  
  146.  
  147.     move.l    aslreq,a0
  148.     move.l    8(a0),asldir
  149.     
  150.     
  151.     MOVE.L    asldir,A0  
  152.     lea    path,A1
  153. cp:    MOVE.B    (A0)+,(A1)+
  154.     BNE.S    cp
  155.     
  156.     suba    #2,a1
  157.  
  158.     cmp.b    #':',(A1)+
  159.  
  160.     beq    begin
  161.  
  162.     move.b    #'/',(A1)+
  163.     
  164. begin:    
  165.     
  166.     move.l    aslfile,a0    
  167. cq:    move.b    (A0)+,(A1)+
  168.     BNE.S    cq
  169.     
  170.     move.b    #10,(A1)+
  171.                               
  172. ;get the size of the file
  173.     
  174.     lea    path,a0    
  175.                      
  176.     CALLFU    GetSize
  177.                  
  178.     tst.l    d0
  179.     
  180.     beq    runreq
  181.     
  182.     move.l    d0,d7
  183.  
  184.  
  185. ;free the memory
  186.  
  187.     move.l    d7,d0
  188.  
  189.     move.l    #65538,d1
  190.  
  191.     CALLEXEC AllocMem
  192.     
  193.     tst.l    d0
  194.     
  195.     beq    runreq
  196.     
  197.  
  198.     move.l    d0,d6
  199.     
  200.  
  201.  
  202. ;load in sound
  203.  
  204.  
  205.     move.l    d6,a0
  206.     move.l    #path,d0
  207.             
  208.     CALLFU    LoadSound
  209.     
  210.     tst.l    d0
  211.     
  212.     beq    runreq
  213.     
  214.  
  215.         
  216.     move.l    d0,d5    
  217.     move.w    d0,frqstore                
  218.     
  219.     
  220. ;caluclate the period
  221.  
  222.     move.l    #3579545,d1
  223.  
  224.     divu    d5,d1
  225.     move.l    d1,d5    
  226.     
  227. ;playsound
  228.  
  229.     move.l    d6,a0
  230.     
  231.     move.l    d7,d0
  232.     move.l    #1,d1
  233.     move.l    d5,d2
  234.     move.l    #64,d3
  235.             
  236.     CALLFU    PlaySound
  237.     move.l    d0,d4                        
  238.  
  239.  
  240.  
  241.  
  242.  
  243.         
  244.     move.l    aslreq,a0
  245.     move.l    32(a0),d2
  246.     move.l    lstore,d0
  247.     cmp.l    d2,d0
  248.     
  249.     beq    noloopy2
  250.     
  251.     
  252.  
  253. ;delay a bit
  254.  
  255.     move.l    #0,d1
  256.     move.w    frqstore,d1
  257.     
  258.     move.l    d7,d0
  259.     
  260.     divu.l    #1000,d1
  261.     divu.l    d1,d0
  262.     divu.l    #20,d0
  263.     add.l    #10,d0
  264.     move.l    d0,d1
  265.     CALLDOS    Delay
  266.     
  267.  
  268.                 
  269. ;stop sound
  270.     move.l    d4,a0
  271.     CALLFU    StopSound
  272.      
  273.     
  274. ;free the memory
  275.  
  276.     move.l    d6,a1
  277.     move.l    d7,d0    
  278.     CALLEXEC FreeMem
  279.  
  280.  
  281.     bra    loopy2
  282.     
  283.  
  284.  
  285.  
  286. noloopy2
  287.  
  288.  
  289.  
  290. ;rereq the sound file
  291.  
  292.     move.l    aslreq,a0    
  293.     lea    tags(pc),a1
  294.  
  295.     CALLASL    AslRequest     
  296.     
  297.     move.l    d0,aslres
  298.  
  299.  
  300. ;test output
  301.  
  302.     cmp    #0,d0
  303.     
  304.     beq    exitpress
  305.     
  306. ;update the patten
  307.  
  308.     
  309.     move.l    aslreq,a0
  310.     move.l    52(a0),a0
  311.     
  312.     
  313.     lea    pattern,a1
  314.     
  315. loop2:    MOVE.B    (A0)+,(A1)+
  316.     BNE.S    loop2
  317.     
  318.     
  319.  
  320.  
  321.             
  322. ;stop sound
  323.     move.l    d4,a0
  324.     CALLFU    StopSound
  325.      
  326.     
  327. ;free the memory
  328.  
  329.     move.l    d6,a1
  330.     move.l    d7,d0    
  331.     CALLEXEC FreeMem
  332.  
  333.  
  334.  
  335.  
  336.  
  337.     bra    settheaddrs
  338.  
  339. ;if exit was hit.
  340.  
  341. exitpress
  342. ;stop sound
  343.     move.l    d4,a0
  344.     CALLFU    StopSound
  345.      
  346.     
  347. ;free the memory
  348.  
  349.     move.l    d6,a1
  350.     move.l    d7,d0    
  351.     CALLEXEC FreeMem
  352.  
  353.  
  354.  
  355.     
  356. ;free the requester 
  357. freereq
  358.  
  359.     move.l    aslreq,a0
  360.  
  361.     CALLASL    FreeAslRequest
  362.  
  363.  
  364. ;close future library
  365.  
  366. exitclosefut
  367.  
  368.     move.l    _futurebase,a1
  369.     CALLEXEC CloseLibrary
  370.  
  371.  
  372. ;close dos lib
  373.  
  374. exitclosedos 
  375.  
  376.     move.l    _DOSBase,a1            base needed in a1        
  377.     
  378.     CALLEXEC CloseLibrary
  379.     
  380.  
  381. ;close asl lib
  382.  
  383. exitcloseasl
  384.     move.l    _ASLBase,a1
  385.     CALLEXEC CloseLibrary
  386.         
  387.     
  388. ;end of program
  389.  
  390. exitcloseall
  391.  
  392.     move    #0,d0
  393.     rts
  394.  
  395.  
  396. ;data for program
  397.  
  398.  
  399. ;strings
  400.  
  401. version        dc.b    '$VER: ASLPlaySound V1.1 -- By Mark Retallack 1996',0
  402. funame        dc.b    'future.library',0
  403. dosname        dc.b     'dos.library',0
  404. aslname        dc.b    'asl.library',0
  405. title        dc.b    'Select Sample To Play:',0
  406. runs        dc.b    'Play',0
  407. cancel        dc.b    'Exit',0
  408. pattern        dc.b    '~(#?.info)',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  409.  
  410.  
  411. ;storage
  412.  
  413.  
  414.  
  415. _stdout        ds.l    1
  416. _futurebase    ds.l    1
  417. _DOSBase    ds.l    1
  418. _ASLBase    ds.l    1
  419. aslreq        ds.l    1
  420. aslres        ds.l    1
  421. asldir        ds.l    1
  422. aslfile        ds.l    1
  423. lstore        ds.l    1
  424. frqstore    ds.w    1
  425. path        ds.b    160
  426.  
  427.  
  428. ;tags for requester
  429.  
  430.  
  431. tags    dc.l    ASL_Hail,title
  432.     dc.l    ASL_FuncFlags,FILF_MULTISELECT|FILF_PATGAD
  433.     dc.l    ASL_LeftEdge,50
  434.     dc.l    ASL_TopEdge,11
  435.     dc.l    ASL_Width,300
  436.     dc.l    ASL_Height,200
  437.     dc.l    ASL_OKText,runs
  438.     dc.l    ASL_CancelText,cancel
  439.     dc.l    ASL_Pattern,pattern
  440.     dc.l    0
  441.  
  442.  
  443.